#include <windows.h>
#include "CLotItemPacket.h"
#include "structs.h"

CLotItemPacket::CLotItemPacket(CBaseEntity * pLotter, unsigned char slotID, unsigned short lotterLot, bool displayName) {
	memset(this->data, 0, 0x1E*2);
	this->type = 0xD3;
	this->size = 0x1E;
	
	unsigned short lotterTargID = pLotter->getTargId();
	unsigned int lotterID = pLotter->getId();
	
	memcpy(this->data+0x08-0x04, &lotterID, 4);
	memcpy(this->data+0x10-0x04, &lotterTargID, 2);
	memcpy(this->data+0x12-0x04, &lotterLot,2);
	if (displayName == true) {
		memcpy(this->data+0x26-0x04, pLotter->m_name, 16);
	}
	this->data[0x14-0x04] = slotID;	
}

CLotItemPacket::CLotItemPacket(unsigned char slotID, unsigned char winMsg) {
	memset(this->data, 0, 0x1E*2);
	this->type = 0xD3;
	this->size = 0x1E;
	
	this->data[0x14-0x04] = slotID;	
	this->data[0x15-0x04] = winMsg;
}

CLotItemPacket::CLotItemPacket(CBaseEntity * pLotter, CBaseEntity * pWinner, unsigned char slotID, unsigned short lotterLot, unsigned short winnerLot, unsigned char winMsg) {
	memset(this->data, 0, 0x1E*2);
	this->type = 0xD3;
	this->size = 0x1E;
	
	unsigned short lotterTargID = pLotter->getTargId();
	unsigned int lotterID = pLotter->getId();
	unsigned short winnerTargID = pWinner->getTargId();
	unsigned short winnerID = pWinner->getId();
	
	memcpy(this->data+0x08-0x04, &lotterID, 4);
	memcpy(this->data+0x10-0x04, &lotterTargID, 2);
	memcpy(this->data+0x04-0x04, &winnerID, 4);
	memcpy(this->data+0x0C-0x04, &winnerTargID, 2);
	memcpy(this->data+0x0E-0x04, &winnerLot,2);
	memcpy(this->data+0x12-0x04, &lotterLot,2);
	memcpy(this->data+0x16-0x04, pWinner->m_name, 16);
	memcpy(this->data+0x26-0x04, pLotter->m_name, 16);

	this->data[0x14-0x04] = slotID;
	this->data[0x15-0x04] = winMsg;
	
}

CLotItemPacket::CLotItemPacket(CBaseEntity * pWinner, unsigned char slotID, unsigned short winnerLot, unsigned char winMsg) {
	memset(this->data, 0, 0x1E*2);
	this->type = 0xD3;
	this->size = 0x1E;
	
	unsigned short winnerTargID = pWinner->getTargId();
	unsigned short winnerID = pWinner->getId();
	
	memcpy(this->data+0x04-0x04, &winnerID, 4);
	memcpy(this->data+0x0C-0x04, &winnerTargID, 2);
	memcpy(this->data+0x0E-0x04, &winnerLot,2);
	memcpy(this->data+0x16-0x04, pWinner->m_name, 16);

	this->data[0x14-0x04] = slotID;
	this->data[0x15-0x04] = winMsg;
}


CLotItemPacket::~CLotItemPacket() {

}
